<?php

namespace App\Traits\Api;


trait SuccessOrFailure
{

    public function success($message = '操作成功！', $redirect = '', $data = [])
    {
        return $this->responseSuccessOrFailure('success', $message ?: '操作成功！', $redirect, $data);
    }

    public function failure($message = '操作失败！', $redirect = '', $data = [])
    {
        return $this->responseSuccessOrFailure('failure', $message ?: '操作失败！', $redirect, $data);
    }

    protected function responseSuccessOrFailure($status, $message, $redirect, $data = [])
    {
        $result_data = compact('status', 'message', 'redirect', 'data');
        return $result_data;
    }

}